package com.more.offer.algorithm.leetcode.lcode11;

/**
 * @author pinoc
 * @date 2021/8/9
 * @description 盛水问题，左右边界收敛法
 */
class Solution {
	public int maxArea(int[] height) {
		int maxArea = 0;
		for(int i= 0, j = height.length -1; i < j ;){
			int minHeight = height[i] < height[j] ? height[i++] : height[j--];
			int currArea = (j - i + 1) * minHeight;
			maxArea = Math.max(maxArea, currArea);
		}
		return maxArea;
	}
}
